#include "Student_info.h"
#include <iostream>

using std::istream;
using std::cout;
using std::endl;
using std::vector;

bool compare(const Student_info& x, const Student_info& y){
    return x.name < y.name;
}

istream& read(istream& is, Student_info& s){
    cout << "Enter student info: name, midterm, final: " << endl;
    cout << "type 'z' to finish." << endl;
    is >> s.name >> s.midterm >> s.final_grade;
    read_hw(is, s.homework);
    return is;
}

istream& read_hw(istream& in, vector<double>& hw){
    if (in){
        cout << "Enter homework grades: " <<endl;
        cout << "type 'z' to finish." << endl;
        //get rid of previous contents
        hw.clear();

        //read homework grades
        double x;
        while (in >> x){
            hw.push_back(x);
        }

        //clear the stream so input will work for the next student
        in.clear();
    }
    return in;
}
